package com.dingup.paike.dao;

import com.dingup.paike.adapter.pk.PkLessonUserAdapter;
import com.dingup.paike.adapter.pk.message.RemindOfClassForUser;
import com.dingup.paike.bean.aobean.StatisticsClassHourAO;
import com.dingup.paike.enums.PkLessonUserTypeEnum;
import com.dingup.paike.mappers.BaseMapper;
import com.dingup.paike.model.pk.PkLessonUser;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;


public interface PkLessonUserMapper extends BaseMapper<PkLessonUser> {

    List<PkLessonUser> getPkLessonUserByPkLessonIdAndType(@Param("pkLessonId") Integer pkLessonId,
                                                          @Param("type") PkLessonUserTypeEnum type);

    PkLessonUser getByPkLessonIdAndType(@Param("pkLessonId") Integer pkLessonId,
                                        @Param("userId") String userId,
                                        @Param("type") PkLessonUserTypeEnum type);

    List<PkLessonUserAdapter> getPkUserLeftJoinPkLesson(@Param("userIds") List<String> userIds,
                                                        @Param("beginTime") Date beginTime, @Param("endTime") Date endTime, @Param("pkLessonId") Integer pkLessonId);

    void insertForBatch(@Param("list") List<PkLessonUser> list);

    /**
     * 获取课节中的人数
     * @param pkLessonId
     * @return
     */
    Integer getMemberCountExceptMaster(Integer pkLessonId);

    /**
     * 获取用户的上课提醒
     * @param userId
     * @param userType 用户类型 老师学生班主任
     * @param before
     * @return
     */
    RemindOfClassForUser getRemindOfClassForUser(@Param("userId") String userId,
                                                 @Param("userType") PkLessonUserTypeEnum userType,
                                                 @Param("before") String before);

    /**
     * 消息提醒--根据id获取相关内容
     *
     * @param pkLessonId
     * @param before
     * @return
     */
    PkLessonUserAdapter getPkLessonAndTeacherMsg(@Param("pkLessonId") Integer pkLessonId, @Param("before") String before);

    /**
     * 批量修改课时
     *
     * @param pkLessonId
     * @param userIds
     * @param classHour
     * @return
     */
    int updateUserClassHourForBatch(@Param("pkLessonId") Integer pkLessonId,
                                @Param("userIds") List<String> userIds,
                                @Param("classHour") Float classHour);

    /**
     * 获取某天的所有课程
     *
     * @param before "2018-01-01"
     * @return
     */
    List<PkLessonUserAdapter> getPkLessonMsgByBeginTimeDay(@Param("before") String before);

    /**
     * 删除班级中人员同时删除该人员的未完成的课节
     *
     * @param userId
     * @param classId
     * @param type
     */
    void deleteStudentByStudentId(@Param("userId") String userId,
                                  @Param("classId") Integer classId,
                                  @Param("type") PkLessonUserTypeEnum type);

    /**
     * 课时统计
     *
     * @param dateTime
     * @param typeEnum
     * @return
     */
    List<StatisticsClassHourAO> getStatisticsClassHourByTimeAndType(@Param("dateTime") String dateTime,
                                                                    @Param("studentName") String studentName,
                                                                    @Param("type") PkLessonUserTypeEnum typeEnum);

    /**
     * 课时统计详情
     *
     * @param userId
     * @param dateTime
     * @param typeEnum
     * @return
     */
    List<PkLessonUserAdapter> getStatisticsClassHourDetails(@Param("userId") String userId,
                                                            @Param("dateTime") String dateTime,
                                                            @Param("type") PkLessonUserTypeEnum typeEnum,
                                                            @Param("classIds") List<Integer> classIds);

    /**
     * 通过课节id批量删除学生老师班主任
     *
     * @param pkLessonIds
     */
    void deleteByPkLessonIds(@Param("pkLessonIds") List<Integer> pkLessonIds);
}